home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / e-lang / dirlist.lha / dirlist / examples / DirList_Example2.e < prev    next >
Text File  |  1996-05-02  |  991b  |  44 lines

  1. /*
  2. ** DirList_Example 2
  3. **
  4. ** Methods: setdir(), read(), sort(), first(), obj()
  5. **          succ()
  6. **
  7. ** This code shows an example of parsing with pattern matching
  8. **
  9. ** This code is placed in Public Domain
  10. **
  11. ** (C)Copyright 1996 Fabio Rotondo
  12. **
  13. */
  14.  
  15.  
  16. MODULE 'Fabio/DirList_oo',       -> Our MAGIC MODULE!
  17.        'tools/exceptions'
  18.  
  19. PROC main() HANDLE
  20.   DEF dl:PTR TO dirlist
  21.  
  22.   NEW dl.dirlist()               -> Here we init the dirlist obj
  23.  
  24.   dl.setdir('ram:')             -> This is the working dir
  25.   WriteF('Reading...\n')
  26.   dl.read(FALSE, TRUE, '#?.info')-> Read FILES only, matching #?.info
  27.   WriteF('Sorting!\n')
  28.   dl.sort()                      -> NOTE: This sort is CASE sensitive
  29.  
  30.   WriteF('Done!\n--------------\n')
  31.  
  32.   IF dl.first()                  -> Here we pos TO the first item
  33.     REPEAT
  34.       WriteF('\s\n',dl.obj())    -> Here we show the name
  35.     UNTIL dl.succ()=FALSE        -> AND get the succ()
  36.   ENDIF
  37.  
  38. EXCEPT DO
  39.   report_exception()
  40.   END dl
  41.   CleanUp(0)
  42. ENDPROC
  43.  
  44.